package sig.web.struts.actions;

import sig.model.entities.Consultant;
import sig.model.entities.Consultant.Level;
import sig.model.entities.Employee;
import sig.util.IServices;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class EmployeeAction extends ActionSupport implements
		ModelDriven<Employee> {

	/**
	 * 
	 */
	Employee employee = new Employee();

	private static final long serialVersionUID = 1L;

	private IServices services;
	private String career;
	private String level;
	private String laptopBonus;
	
	public String execute() {
		return SUCCESS;
	}

	public String save() {

		Consultant c;
		
		boolean laptop=true;
		
		if (laptopBonus.equals("No")){
			
			laptop=false;
			
		}
		if (employee.getType() != null) {

			switch (employee.getType()) {

			case consultor:

				c = new Consultant();

				c.setName(employee.getName());
				c.setLastName(employee.getLastName());
				c.setBirthDate(employee.getBirthDate());
				c.setNationality(employee.getNationality());
				c.setDolar(employee.getDolar());
				c.setPesos(employee.getPesos());
				c.setFee(employee.getFee());
				c.setType(employee.getType());
				c.setTypeOfFee(employee.getTypeOfFee());
				c.setLevel(Level.valueOf(level));
				c.setLaptop(laptop);
				c.setCareer(career);
				c.setGender(employee.getGender());
				c.setStatus(employee.getStatus());
				services.saveEmployee(c);

				
				break;

			case administrativo:

				services.saveEmployee(employee);

				break;

			default:
				break;
			}
		}

		return SUCCESS;
	}

	@Override
	public Employee getModel() {

		return employee;
	}

	public IServices getServices() {
		return services;
	}

	public void setServices(IServices services) {
		this.services = services;
	}

	public String getCareer() {
		return career;
	}

	public void setCareer(String carreer) {
		this.career = carreer;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	


	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	

	

	public String getLaptopBonus() {
		return laptopBonus;
	}

	public void setLaptopBonus(String laptopBonus) {
		this.laptopBonus = laptopBonus;
	}

}
